Skip to content

Keep the Spotify example login callback on loopback - #552

Merged
robgruen merged 1 commit into
mainfrom
fix/music-loopback-callback
Nov 30, 2026
Merged

robgruen merged 1 commit into
mainfrom
fix/music-loopback-callback

Conversation

@robgruen

Copy link
Copy Markdown
Contributor

The TypeScript music example now binds its login server to 127.0.0.1 and uses that same address in the Spotify redirect URI. Existing users of the example should register http://127.0.0.1:PORT/callback in their Spotify app settings in place of the old localhost URI.

The server loads the HTML page once, before it starts listening. The first callback serves it from memory; a repeat gets 410 Gone. A denied login or missing token gets an explicit error and closes the listener so the CLI can continue without Spotify. This removes the request-time file access flagged by code scanning alert 4 without adding middleware or changing the TypeChat library.

Verification (Node 24.22.1): npm run build-all and npm test passed; all 594 tests passed. Three new offline tests use real loopback requests and a stubbed browser; they cover the bind address and redirect URI, serving after the page file is removed, repeat callbacks, and shutdown on success and failure. Live Spotify sign-in was not exercised.

Serve the one-shot callback page from memory and finish denied, repeated, and missing-token requests explicitly. Document the matching redirect URI and cover the listener with offline tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 30, 2026 18:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The Spotify login callback changes have no active review issues.

No open issues 🎉

What changed in this PR

This PR confines the TypeScript music example’s Spotify login callback to IPv4 loopback and removes request-time HTML file access, without changing the TypeChat library.

Changes:

  • Bind the login server and redirect URI to 127.0.0.1, with updated setup instructions.
  • Preload callback HTML, reject repeat callbacks, and close the listener on successful or failed authorization.
  • Add three offline tests covering loopback binding, callback handling, and listener shutdown.
File Description
typescript/​tests/​examples.test.mjs Adds offline login tests using loopback requests and a stubbed browser.
typescript/​examples/​music/​src/​authz.ts Restricts binding to loopback, preloads HTML, and handles authorization completion and errors.
typescript/​examples/​music/​README.md Documents the loopback redirect URI and migration from localhost.

Review effort: Balanced

@robgruen
robgruen merged commit d61044d into main Nov 30, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants